﻿using DotNetCommon.Extensions;
using NUnit.Framework;
using Shouldly;
using System;
using System.Collections.Generic;
using System.Text;

namespace Test.MySql
{
    [TestFixture]
    internal class ColumnTypesTestsDateTime : TestBase
    {
        #region 模型
        public class Model
        {
            public DateTime t_datetime { get; set; }

        }
        #endregion

        [SetUp]
        public void Setup()
        {
            //            db.Manage.DropTableIfExist("test");
            //            db.ExecuteSql(@"
            //create table test.test(
            //	t_timestamp time
            //)");
            //            db.ExecuteSql("insert into test.test(t_timestamp)values(current_timestamp)");
        }

        [Test]
        public void Test()
        {
            var dic = db.SelectDictionary("select * from test");

            var model = db.SelectModel<Model>("select * from test");

        }

        [Test]
        public void TestOrmRead()
        {
            //var models = db.SelectModelList<Model>("select * from test");
            //models[0].t_bit.ShouldBe(true);
            //models[0].t_bit8.ShouldBe((byte)0x01);
            //models[0].t_bit16.ShouldBe((ushort)0x0002);
            //models[0].t_bit32.ShouldBe((uint)0x0000_0003);
            //models[0].t_bit64.ShouldBe((ulong)0x0000_0000_0004);
            //models[0].t_bit4.ShouldBe((byte)0x05);
        }

        [Test]
        public void TestOrmWrite()
        {
            //db.Manage.TruncateTable("test");
            //var model = new Model
            //{
            //    t_bit = true,
            //    t_bit8 = (byte)0x01,
            //    t_bit16 = (ushort)0x0002,
            //    t_bit32 = (uint)0x0000_0003,
            //    t_bit64 = (ulong)0x0000_0000_0004,
            //    t_bit4 = (byte)0x05
            //};
            //var res = db.Insert("test", model.ToDictionary());
            //res.ShouldBe(1);
            //var models = db.SelectModelList<Model>("select * from test");

            //models[0].t_bit.ShouldBe(true);
            //models[0].t_bit8.ShouldBe((byte)0x01);
            //models[0].t_bit16.ShouldBe((ushort)0x0002);
            //models[0].t_bit32.ShouldBe((uint)0x0000_0003);
            //models[0].t_bit64.ShouldBe((ulong)0x0000_0000_0004);
            //models[0].t_bit4.ShouldBe((byte)0x05);
        }
    }
}
